#include "ReadMixture.hpp"
#include "gtest_wrapper.hpp"
#include <algorithm>
#include "Assertions.hpp"
#include "ParseException.hpp"

namespace readmixture
{

TEST(ReadMixture, ReadMixFor2People)
{
	std::vector<dna::marker> mix;
	readmixture::ReadMixture rm;
	std::string namem="../input_data/mixture2.txt";
	int a=2;
	try
	{
		mix=rm.parseMixFromFile(namem,a);
	}
        catch(std::exception *e)
        {
            
        }
	assertMixture(mix, "(A,B)(A,C)");
}

TEST(ReadMixture, ReadMixFor3People)
{
	std::vector<dna::marker> mix;
	readmixture::ReadMixture rm;
	std::string namem="../input_data/mixture3.txt";
	int a=3;
	try
	{
		mix=rm.parseMixFromFile(namem,a);
	}
        catch(std::exception *e)
        {
           
        }
	assertMixture(mix, "(A,B,C,D,X,Y)(A,B,C)");

}

TEST(ReadMixture, CheckProfileInMixture)
{
	dna::profile p;
	dna::profile pa;
	std::vector<dna::marker> mix;
	readmixture::ReadMixture rm;
	std::string namem="../input_data/mixture2.txt";
	std::string namepa="../input_data/profiles2a.txt";
	std::string namep="../input_data/profiles2.txt";
	int a=2;
	try
	{
		pa= rm.parseProFromFile(namepa);
		p= rm.parseProFromFile(namep);
		mix=rm.parseMixFromFile(namem,a);
	}
        catch(std::exception *e)
        {
           
        }
	EXPECT_TRUE(rm.checkProfileInMixture(mix,pa));	
	EXPECT_TRUE(rm.checkProfileInMixture(mix,p));

}


TEST(ReadMixture, ReadNonExistingFile)
{
	readmixture::ReadMixture rm;
	std::string namem="../input_data/nosuchfile.txt";
	int a=3;
		
	EXPECT_THROW(rm.parseMixFromFile(namem,a),exc::FOpenException*);
		
}

TEST(ReadMixture, ReadProfiles)
{
	dna::profile p;
	readmixture::ReadMixture rm;
	std::string namep="../input_data/profiles2.txt";
	try
	{
		p= rm.parseProFromFile(namep);
	}

        catch(std::exception *e)
        {
            
        }
	dna::profile &x=p;
	assertProfile(x, "(A,B)(A,A)");
}
}
